{% from "layout/errorlist.html" import errorlist %}
{% macro login_form(form, next_url='', action=None, only_pwreset=False) -%}
  {{ errorlist(form) }}
  <form method="post" action="{{ action if action != None else url('users.login') }}">
    {% csrf_token %}
    <input type="hidden" name="next" value="{{ next_url }}" />
      <ul>
        <li class="cf">
          <label for="id_username">{{ _('Username:') }}</label>
          {{ form.username|safe }}
        </li>
        <li class="cf">
          <label for="id_password">{{ _('Password:') }}</label>
          {{ form.password|safe }}
        </li>
      </ul>
      <div class="login-submit">
        <div class="button-wrap">
          <input type="hidden" name="login" value="1">
          <button type="submit"  data-event-category="account" data-event-action="login" data-type="submit" data-name="login" class="button dark" data-progress="{{ _('Logging in...') }}" data-done="{{ _('Logged in!') }}" data-reset="{{ _('Log in') }}">{{ _('Log in') }}</button>
        </div>
        <p class="help-text">
        {% trans %}
        Support.mozilla.org will soon only support  Firefox Accounts logins.
        Learn more in our <a href="https://support.mozilla.org/en-US/kb/firefox-accounts-mozilla-support-faq">FAQ</a>.
        {% endtrans %}
        </p>
      </div>
  </form>
  <div id="login-help">
    {% if only_pwreset %}
      <a id="reset_password" target="_blank" href="{{ url('users.pw_reset') }}">{{ _("My password isn't working.") }}</a>
    {% else %}
      <h3>{{ _('Login Problems?') }}</h3>
      <ul>
        <li>
          <a href="{{ url('users.pw_reset') }}">
            {{ _("My password isn't working.") }}
          </a>
        </li>
        <li>
          <a href="{{ url('users.forgot_username') }}">
            {{ _('I forgot my username.') }}
          </a>
        </li>
        <li>
          <a href="{{ url('users.resend_confirmation') }}">
            {{ _("I didn't get a confirmation email.") }}
          </a>
        </li>
      </ul>
    {% endif %}
  </div>
{%- endmacro %}

{% macro personal_tabs(user, selected) -%}
  <ul id="user-nav" class="sidebar-nav">
    <li {{ selected|class_selected('my-profile') }}>
      <a href="{{ profile_url(user) }}">{{ _('My profile') }}</a>
    </li>
    <li {{ selected|class_selected('edit-profile') }}>
      <a href="{{ url('users.edit_my_profile') }}">{{ _('Edit my profile') }}</a>
    </li>
    <li {{ selected|class_selected('edit-settings') }}>
      <a href="{{ url('users.edit_settings') }}">{{ _('Edit settings') }}</a>
    </li>
    <li {{ selected|class_selected('edit-watches') }}>
      <a href="{{ url('users.edit_watch_list') }}">{{ _('Manage watch list') }}</a>
    </li>
  </ul>
{%- endmacro %}
